/*
 * Copyright (c) 2021. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.pobing.service.impl;

import com.pobing.grpc.lib.hello.HelloRequest;
import com.pobing.grpc.lib.hello.HelloResponse;
import com.pobing.grpc.lib.hello.HelloServiceGrpc;
import com.pobing.service.HelloService;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;

/**
 * @author xfworld
 * @since create on 2021-06-28.
 **/
@GrpcService
public class HelloServiceImpl extends HelloServiceGrpc.HelloServiceImplBase implements HelloService{

    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
        String name = request.getName();
        System.out.println("received client name is " + name);
        HelloResponse response = HelloResponse.newBuilder().setCode("0000").setMessage("hello "+ name).build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }
}
